﻿
<div>

        @{
            if (User.Identity.IsAuthenticated)
            {
                FollowPeers.Models.FollowPeersDBEntities followPeersDB = new FollowPeers.Models.FollowPeersDBEntities();
                string name = Membership.GetUser().UserName;
                FollowPeers.Models.UserProfile myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
                
            <div class="navbar navbar-fixed-top" >
			      <div class="navbar-inner">
			        <div class="container">
			            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			      </a>
			           <a class="brand" href="@Url.Content("~/Notice/Index/?id=" + @myprofile.UserProfileId)">Follow Peers</a>
			        <ul class="nav">
			          <li class="divider-vertical"></li>
			          <li class=""> <a href="@Url.Content("~/Notice/Index/?id=" + @myprofile.UserProfileId)">Home</a></li>
			          <li class="divider-vertical"></li>
			          <li class=""> <a href="@Url.Content("~/Profile/Index/?id=" + @myprofile.UserProfileId)">Profile</a></li>
			          <li class="divider-vertical"></li>
		          	  <li class=""> <a href="@Url.Content("~/Profile/FollowedByList/?name=" + Session["username"])" title="Your Peer List">Peers</a></li>                
					  <li class="divider-vertical"></li>
                       <li>
                        <a id="Notification" title="Notifications"><img src="../../Content/images/icons/16x16/newspaper.png" /><span style="color:orange;" id="newCount"></span></a>
                          <div id="noti"><div class="search-background" style="margin-top:-26px">
                </div><div class ="typeahead dropdown-menu pull-right" id="noti_cont" style="display:none;border: 1px solid #AAA;-webkit-box-shadow: 0 15px 30px #888;"></div>
                </div>
                      </li>
                <li class="divider-vertical"></li>
            <li><a href="../../Message/Index" title="Check Mails">
                <img src="../../Content/images/icons/16x16/email.png" /></a></li>
                <li class="divider-vertical"></li>
                      
                </ul>
                <ul class="nav pull-right">
                
                <form class="navbar-search">
		 			 <input type="text" class="search-query" placeholder="Search" id="search"/>
				</form>
                <li class="dropdown" style="margin-left:-10px">
                      <a class="dropdown-toggle" data-toggle="dropdown" href="#"> <b class="icon-cog icon-white"></b>
					      </a>
                        <ul class="dropdown-menu">
                            <li class="">@Html.ActionLink("Update Profile", "Edit", "Profile")</li>
                            <li class="">@Html.ActionLink("Privacy", "TierFollowers", "Profile")</li>
                            <li class="">@Html.ActionLink("Log Off", "LogOff", "Account")</li>
                        </ul>
                      </li>
                <div id="content"><div class="search-background" style="margin-top:-26px">
                </div><div class ="typeahead dropdown-menu pull-right" id="sub_cont" style="display:none;border: 1px solid #AAA;-webkit-box-shadow: 0 15px 30px #888;"></div>
                </div>  
                </ul>      
				</div>
	        </div>
		    </div>
                
            
            }
        }

</div>
<div class="clear">
</div>
<script type="text/javascript" language="javascript">
 $(document).ready(function () {
        //show loading bar
        $('#sub_cont').hide();
        $('#content').hide();
        $('#newCount').load('../../Profile/GetNumberofNewNoti');

        function showLoader() {
            $('.search-background').fadeIn(200);
            $('#content').show();
        }

        $(document).click(function (event) {
            if (!($(event.target).is('#content') || $(event.target).parents('#content').length || $(event.target).is('#content'))) {
                $('#content').hide();
                if (!($(event.target).is('#Notification') || $(event.target).parents('#Notification').length || $(event.target).is('#Notification'))) {
                    $('#noti_cont').hide();
                }
            }
        });


        $('#Notification').click(function () {
            $('#noti_cont').show();
            $('#Notification').css("background", "#555");
            //                        if ($('#newCount').innerHTML != "") {
            //                            $('#noti_cont').css("margin-left", "-205px");
            //                        }
            //                        else {
            //                            $('#noti_cont').css("margin-left", "-214px");
            //                        }
            $('#newCount').load("../../Profile/MarkNotificationsasSeen");

            $("#noti_cont").load("../../Profile/GetNotifications");
        });

        //hide loading bar

        function hideLoader() {
            $('#sub_cont').fadeIn(50);
            $('.search-background').fadeOut(50);
        };

        $('#search').keyup(function (e) {
            lastKeyPressCode = e.keyCode;
            if ($("#search").val().length > 1) {
                if (lastKeyPressCode != 46 && !(lastKeyPressCode > 8 && lastKeyPressCode < 32)) {
                    //showLoader();
                    $('#content').show();
                    $('#sub_cont').fadeIn(50);
                    $("#content #sub_cont").load("../../Profile/searchajax?val=" + $("#search").val(), hideLoader());
                }

            }
            if (e.keyCode == 13) {
                //showLoader();
                $('#content').show();
                $('#sub_cont').fadeIn(50);
                $("#content #sub_cont").load("../../Profile/searchajax?val=" + $("#search").val(), hideLoader());
            }
        });

        $(".searchBtn").click(function () {
            //showLoader();
            //   $('#sub_cont').fadeIn(1500);
            //   $("#content #sub_cont").load("../../Profile/searchajax?val=" + $("#search").val(), hideLoader());
            if ($("#search").val() == "Search")
                location.href = "../../Profile/Search";
            else
                location.href = "../../Profile/Search?keywords=" + $("#search").val();
        });


        function puthint(divname, hinttext) {
            $(document).ready(function () {

                // Define what happens when the textbox comes under focus
                // Remove the watermark class and clear the box
                $(divname).focus(function () {

                    $(this).filter(function () {

                        // We only want this to apply if there's not 
                        // something actually entered
                        return $(this).val() == "" || $(this).val() == hinttext

                    }).removeClass("watermarkOn").val("");

                });

                // Define what happens when the textbox loses focus
                // Add the watermark class and default text
                $(divname).filter(function () {

                    // We only want this to apply if there's not
                    // something actually entered
                    return $(this).val() == ""

                }).addClass("watermarkOn").val(hinttext);

                $(divname).blur(function () {

                    $(this).filter(function () {

                        // We only want this to apply if there's not
                        // something actually entered
                        return $(this).val() == ""

                    }).addClass("watermarkOn").val(hinttext);

                });

            });
        }
        puthint("#search", "Search");
    });
            </script>
